<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>	自定义函数，实现交换数组中两个元素的功能，带三个参数</title>
	<script>
		var arr1=[1,2]
		function fn(arr,index1,index2){
			for(var i=0;i<arr1.length-1;i++)
			{var index1=i;
			 var index2=i+1;
			 var temp=arr1[index1]
			 arr1[index1]=arr1[index2]
			 arr1[index2]=temp;}
			
			console.log(arr1)
		}
		
		fn(arr1,0,1)
	</script>
</head>
<body>
	
</body>
</html>